﻿module StyleTests

open NUnit.Framework
open ComputedStyle
open CssTypes


[<Test>]
let testSpecifiedFontSize() =
    let map = [("font-size", Measure(17.0M, "px"))] |> Map.ofList
    let c = ComputedStyle(map, (fun ()->None))
    Assert.AreEqual(17, c.fontSize)

[<Test>]
let testInheritedFontSize() =
    let map1 = [("font-size", Measure(17.0M, "px"))] |> Map.ofList
    let c1 = ComputedStyle(map1, (fun ()->None))
    let map2 = Map.empty
    let c2 = ComputedStyle(map2, (fun ()->Some(c1)))
    Assert.AreEqual(17, c2.fontSize)

[<Test>]
let testRelativeFontSize() =
    let map1 = [("font-size", Measure(17.0M, "px"))] |> Map.ofList
    let c1 = ComputedStyle(map1, (fun ()->None))
    let map2 = [("font-size", Measure(2M, "em"))] |> Map.ofList
    let c2 = ComputedStyle(map2, (fun ()->Some(c1)))
    Assert.AreEqual(34, c2.fontSize)


[<Test>]
let testUnsetBorderColor() =
    (* should default to text color *)
    let map = [("color", IdentifierTerm("red"))] |> Map.ofList
    let c = ComputedStyle(map, (fun ()->None))
    Assert.AreEqual(System.Windows.Media.Colors.Red, c.borderTopColor)

[<Test>]
let testSetBorderColor() =
    let map = [
                ("color", (IdentifierTerm("red")))
                ("border-top-color", (IdentifierTerm("green")))
                ] |> Map.ofList
    let c = ComputedStyle(map, (fun ()->None))
    Assert.AreEqual(System.Windows.Media.Colors.Green, c.borderTopColor)